package com.g001.model;

import java.util.ArrayList;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;

import com.g001.enums.CharacterType;
import com.g001.model.abilities.Health;
import com.g001.model.abilities.Magic;
import com.g001.model.abilities.Power;
import com.g001.model.abilities.Shield;
import com.g001.model.abilities.StrikeBack;
import com.g001.model.powers.Action;

public class Player extends GCharacter {
	
	public Player(GameContainer container, CharacterType characterType, String name, Vector2f vector2f) throws SlickException {
		this.setCharacterType(characterType);
		this.name = name;
		setPosition(vector2f.copy());
		this.xp = 12345;
		interfacePosition = new Vector2f(10,50);
		// set default animation
		setCurrentAnimation(characterType.getIdleAnim());
		// set the powers (heath, shield etc ...)
		powers = new ArrayList<Power>();
		powers.add(new Health(characterType.getLife(), characterType.getLife(), interfacePosition));
		powers.add(new StrikeBack(10,100, interfacePosition.add(new Vector2f(70,0))));
		powers.add(new Magic(10,100, interfacePosition.add(new Vector2f(70,0))));
		powers.add(new Shield(0,200, interfacePosition.add(new Vector2f(-70,container.getHeight()-200))));
		// actions during one turn
		setActions(new ArrayList<Action>());
		interfacePosition = new Vector2f(10,50);
	}
	

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g)
			throws SlickException {
		super.render(container, game, g);
		g.setColor(new Color(0, 0, 0, 0.5f));
		g.fillOval(x - CharacterType.TILEWIDTH/3, position.y+ CharacterType.TILEHEIGHT-15, 100, 20);
		getCurrentAnimation().draw(x - CharacterType.TILEWIDTH/2, position.y);
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int delta)
			throws SlickException {
		super.update(container, game, delta);
	}

}
